#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_flask_database.py
# author:Jackiex
# datetime:2023/5/22 11:37
# software: PyCharm

"""
  从数据库里面取出来数据，渲染到页面上去
"""

from flask import Flask, render_template
from flask_bootstrap import Bootstrap


import pymysql

app = Flask(__name__)

bootstrap = Bootstrap(app)


@app.route('/userlist')
def user_list():
    conn = pymysql.connect(host='127.0.0.1',user='test',password='123456',db='bbs',charset='utf8')
    cursor = conn.cursor()
    sql = 'select * from user'
    cursor.execute(sql)

    res = cursor.fetchall()

    conn.close()

    return render_template('users.html',u=res)



if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)
